<template>
	<!-- 添加弹框 -->
	<el-dialog title="" visible :show-close="false" :modal-append-to-body="false" class="wrap" @close="cancel" :close-on-click-modal="false">
		<i class="el-icon-close close" @click="cancel" style="color: white;z-index:10;"></i>
	    <div class="bt">发起评价添加</div>
		<el-form label-width="100px" class="form">
			<el-form-item label="选择模板"  style="margin-bottom: 0px;">
				<el-select v-model="vmbid" class="select-block" placeholder="请选择模板名称搜索">
				<el-option :label="v.mc" :value="v.id" v-for="v in mbcomboxlist"></el-option>
			    </el-select>
			</el-form-item>
			<el-form-item label="备注">
				 <el-input v-model="vnote" type="textarea" :rows="2" placeholder="请输入通知内容" icon="add" class="select-block"></el-input>
			</el-form-item>
			<el-form-item label="选择老师" style="margin-bottom: 0px;">
				<el-select v-model="vlsid"  class="code-search" placeholder="请选择老师名称搜索" @change="getlxcomlist">
					<el-option :label="v.zwm" :value="v.id" v-for="v in lscomboxlist"></el-option>
			    </el-select>
			</el-form-item>
			<el-form-item label="" style="margin-left:0px;">
				 <el-checkbox-group v-model="vbjid">
              	   <el-checkbox v-for="v in lxcomboxlist" :label="v.bjid">{{v.bjmc}}</el-checkbox>
                 </el-checkbox-group>
		    </el-form-item>
		</el-form>
		<el-button type="primary" class="submit" @click="submit">发送</el-button>
		<el-button type="danger" class="submit" @click="cancel">退出</el-button>
	</el-dialog>
</template>
<script type="text/javascript">
	import qs from 'qs'
	export default {
		data() {
			return {
				vmbid:'',
				vnote:'',
                vlsid:'',
				vbjid:[],
				dialogTableVisible: true,
				mbcomboxlist:[],//下拉框 动态的
				lscomboxlist:[],//下拉框 动态的
				lxcomboxlist:[],//下拉框 动态的
			}
		},
		created () {
			if(this.$route.query.frompage == 'lspj') {
				this.vmbid = this.$route.query.mbid
			}
			    this.getmbcomlist();
				this.getlscomlist();
				this.getlxcomlist();
		},
		methods: {
			submit() {
			  this.$store.state.loading = true;
				var time1 = this.$.getLocalTimeNo0(Date.parse(this.vbtime));
			    if(!this.vmbid) {
					this.$message.warning('请选择模板');
					this.$store.state.loading = false;
					return;
				} 
				else if(!this.vlsid){
					this.$message.warning('请选择老师');
					this.$store.state.loading = false;
					return;
				}
				else if(!this.vbjid){
					this.$message.warning('请选择发送班级');
					this.$store.state.loading = false;
					return;
				}
				var logininfo = JSON.parse(localStorage.logininfo);
				var params3 = qs.stringify({
					mbid: this.vmbid+'',
					note: this.vnote+'',
					bjid: this.vbjid+'',
					yhid: logininfo.id+'',
					xxid:logininfo.xxid+''
				});
				//执行
				this.axios.post(this.$store.state.api + 'xspjlsbj/insert', params3)
					.then(res => {
						if(res.data.code == 1) {
							this.$emit('close', { type: 'add', cancel: false });
							this.$message.success(res.data.msg);
							this.$store.state.loading = false;
						} else {
							this.$message.warning(res.data.msg);
							this.$store.state.loading = false;
						}
					}).catch(res => {
						this.$message.danger("服务器繁忙，请重试");
						this.$store.state.loading = false;
					})
			},
			getmbcomlist(){
          	 var logininfo = JSON.parse(localStorage.logininfo);
             var params2 = qs.stringify({
                    yhid:logininfo.id,
                    xxid:logininfo.xxid
               })
             //执行
                 this.axios.post(this.$store.state.api + 'xspjlsmb/getmc',  params2 )
                 .then(res => {
                 let data = res.data.data;
                  let list = data.list;
                  this.mbcomboxlist = list;
                 }).catch(res => {
				})
          } ,
			getlscomlist(){
          	 var logininfo = JSON.parse(localStorage.logininfo);
             var params2 = qs.stringify({
                    xxid:logininfo.xxid
               })
             //执行
                 this.axios.post(this.$store.state.api + 'ls/mc',  params2 )
                 .then(res => {
                 let data = res.data.data;
                  let list = data;
                  this.lscomboxlist = list;
                 }).catch(res => {
				})
          } ,
         getlxcomlist(){
         	 var logininfo = JSON.parse(localStorage.logininfo);
             this.searchLoading = true;
             var params2 = qs.stringify({
                	lsid:this.vlsid+'',
                	yhid:logininfo.id+'',
                    xxid:logininfo.xxid+''
               })
             //执行
                 this.axios.post(this.$store.state.api + 'ls/getbj',  params2 )
                 .then(res => {
                 let data = res.data.data;
                  let list = data.list;
                  this.lxcomboxlist = list;
                 }).catch(res => {
				})				
        },
			cancel() {
				this.$emit('close', { type: 'add', cancel: true })
			}
		}
	}
</script>
<style lang="less" scoped>
.wrap {
	text-align: center;
}
.bt{
		position: absolute;
		width: 100%;
		height: 50px;
		margin: 0 auto;
		top: 0;
		left: 0;
		background: #50BFFF;
		color:white;
		text-align:left;
		line-height: 50px;
		font-size: 17px;
		padding-left: 15px;
	}

.form {
	text-align: left;
	margin-top: 20px;
}
 .input {
					width: 300px;
					display: inline-block;
			}

.select-block {
	display: block;
	width: 85%;
}

.submit {
	width: 120px;
}
.weekdiv{
				width: 100%;
				height: 100%;
				margin: 0 auto;
				background: lightblue;


			}
			.wdiv0 {
				width: 90px;
				height: 200px;
				float: left;
				background: lightgoldenrodyellow;
			}
			.wdiv1 {
				width: 40px;
				height: 200px;
				float: left;
				background: lightgoldenrodyellow;
			}
			.wdiv2 {
				width: 40px;
				height: 200px;
				float: left;
				background: lightgoldenrodyellow;
			}
			.wdiv3 {
				width: 40px;
				height: 200px;
				float: left;
				background: lightgoldenrodyellow;
			}
			.wdiv4 {
				width: 40px;
				height: 200px;
				float: left;
				background: lightgoldenrodyellow;
			}
			.wdiv5 {
				width: 40px;
				height: 200px;
				float: left;
				background: lightgoldenrodyellow;
			}
			.wdiv6 {
				width: 40px;
				height: 200px;
				float: left;
				background: lightgoldenrodyellow;
			}
			.wdiv7 {
				width: 40px;
				height: 200px;
				float: left;
				background: lightgoldenrodyellow;
			}
</style>
